﻿using MediatR;
using MS.Data.API.Write.Applicant.Command;
using MS.Data.API.Write.Applicant.Command.RoleInfo;
using MS.Data.Domain;
using MS.Data.ErrorCode;
using MS.Data.Infratructrue.Istanbul;

namespace MS.Data.API.Write.Applicant.CommandHandel.RoleInfo
{

    public class DelRoleCommandHandel : IRequestHandler<DelRoleCommand, APIResult<int>>
    {
        /// <summary>
        /// 权限
        /// </summary>
        IBaseRepository<Role> roleRep;

        public DelRoleCommandHandel(IBaseRepository<Role> roleRep)
        {
            this.roleRep = roleRep;
        }

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="perRep">权限</param>

        /// <summary>
        ///  处理
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">取消</param>
        /// <returns>返回权限列表结果</returns>
        public async Task<APIResult<int>> Handle(DelRoleCommand request, CancellationToken cancellationToken)
        {
            var list = await roleRep.Bysty(request.RoleId);
            list.IsDel = true;

            await roleRep.Update(list);

            return new APIResult<int>()
            {
                code = APIEnum.删除成功,
                data = 1,
                mes = ""
            };

        }

    }
}
